<div class="modal-body no-p">
    <div class="row">
        <div class="col-xs-12">
            <section class="panel panel-primary no-b">
                <header class="panel-heading clearfix brtl brtr">
                    <div class="overflow-hidden">
                        <a href="javascript:;" class="h4 show no-m pt5">投放卡券：${obj.coupon_name!}</a>
                    </div>
                </header>
                <div class="list-group">
                    <a href="javascript:;" class="list-group-item" title="卡券名称">
                        <font color="#0091ff">卡券名称：</font>${obj.coupon_name!}
                    </a>
                    <a href="javascript:;" class="list-group-item" title="券名">
						<font color="#0091ff">券名：</font>${obj.coupon_sub_title!}
                    </a>
                    <a href="javascript:;" class="list-group-item" title="额度">
						<font color="#0091ff">额度：</font>${obj.coupon_fee!}
                    </a>
                </div>
                <form id="couponAddForm" role="form" class="form-horizontal parsley-form" data-parsley-validate 
                  action="${base}/platform/ud/mcoupon/putonDo" method="post">
	                <input type="hidden" name="id" value="${obj.id!}">
                	<div class="row mb10">
	                    <div class="col-lg-12">
	                    	<div class="form-group" >
	                            <label for="coupon_fixed_term" class="col-sm-2 control-label">每人领取数</label>
	                            
	                            <div class="col-sm-8">
	                               <input type="text" value="${obj.max_num!}"  id="max_num" class="form-control" name="max_num"  data-parsley-type="number" placeholder="数量（张）">
	                            </div>
	                        </div>
	                    	<div id="FIX_TIME_RANGE" style="display: none">
		                        <div class="form-group" >
		                           	<label for="coupon_begin_timestamp" class="col-sm-2 control-label">启用时间</label>
		                           	
		                            <div class="col-sm-8">
		                                <div class="col-sm-8 input-group date form_datetime " style="padding-left: 16px;padding-right: 16px;" data-date="1979-09-16T05:25:07Z" data-date-format="dd MM yyyy - HH:ii p" data-link-field="coupon_begin_timestamp">
		                                    <input type="text" size="16" readonly class="form-control" value="<% if(obj.coupon_date_type=='0'){ %>${@date.getDate(obj.coupon_begin_timestamp!)}<% } %>" data-parsley-required="true">
		                                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
		                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
		                                </div>
		                                <input type="hidden" id="coupon_begin_timestamp" name="coupon_begin_timestamp_str" value="<% if(obj.coupon_date_type=='0'){ %>${@date.getDate(obj.coupon_begin_timestamp!)}<% } %>" />
		                            </div>
		                        </div>
		                        <div class="form-group">
		                           <label for="coupon_end_timestamp" class="col-sm-2 control-label">结束时间</label>
		                           	
		                            <div class="col-sm-8">
		                                <div class="col-sm-8 input-group date form_datetime " style="padding-left: 16px;padding-right: 16px;" data-date="1979-09-16T05:25:07Z" data-date-format="dd MM yyyy - HH:ii p" data-link-field="coupon_end_timestamp">
		                                    <input type="text" size="16" readonly class="form-control" value="<% if(obj.coupon_date_type=='0'){ %>${@date.getDate(obj.coupon_end_timestamp!)}<% } %>" data-parsley-required="true">
		                                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
		                                    <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
		                                </div>
		                                <input type="hidden" id="coupon_end_timestamp" name="coupon_end_timestamp_str" value="<% if(obj.coupon_date_type=='0'){ %>${@date.getDate(obj.coupon_end_timestamp!)}<% } %>" />
		                            </div>
		                        </div>
	                        </div>
	                        <div class="form-group" id="FIX_TERM"  style="display: none">
	                            <label for="coupon_fixed_term" class="col-sm-2 control-label">时长</label>
	                            
	                            <div class="col-sm-8">
	                               <input type="text" value="${obj.coupon_fixed_term!}"  id="coupon_fixed_term" class="form-control" name="coupon_fixed_term"  data-parsley-type="number" placeholder="时长（天）">
	                            </div>
	                        </div>
	                    </div>
                    </div>
            	</form>
            </section>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-primary btn-block"  id="save">投放</button>
</div>
<script>
$(document).ready(function () {
	
	var value= ${obj.coupon_date_type};
	if(value==0){
		$("#FIX_TIME_RANGE").css('display','block'); 
		$("#FIX_TERM").css('display','none'); 
	}
	if(value==1){
		$("#FIX_TERM").css('display','block'); 
		$("#FIX_TIME_RANGE").css('display','none'); 
	}
	$('.form_datetime').datetimepicker({
        language:  'zh-CN',
        format:'yyyy-mm-dd hh:ii:ss',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });
	$("#save").on("click",function(){
         $('#couponAddForm').submit();
     });
  	$('#couponAddForm').ajaxForm({
  		dataType: 'json',
  		beforeSubmit: function (arr, form, options) {
            form.find("button:submit").button("loading");
        },
        success: function (data, statusText, xhr, form) {
            if (data.code==0) {
            	 Toast.success(data.msg);
                 setTimeout(function () {
                     $("#save").attr("data-dismiss","modal");
                 }, 1000);
            } else {
                Toast.error(data.msg);
            }
            form.find("button:submit").button("reset");
        }
    });  
});
</script>
